package com.loadmore.common.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.loadmore.common.App;


/**
 * @author sunleilei
 * @date 2018/7/13
 * @time 15:35
 */
public class SPFUtil {
    public SharedPreferences sharedPreferences;
    public SPFUtil(String name) {
        this.sharedPreferences = getPreferences(name);
    }
    public void putString(String key,String value) {
        sharedPreferences.edit().putString(key,value).apply();
    }
    public String getString(String key,String value) {
        return sharedPreferences.getString(key,value);
    }
    public void putLong(String key,Long value) {
        sharedPreferences.edit().putLong(key,value).apply();
    }
    public Long getLong(String key,Long value) {
        return sharedPreferences.getLong(key,value);
    }
    public SharedPreferences getPreferences(String name) {
        return  App.app.getSharedPreferences(name,Context.MODE_PRIVATE);
    }

    public void clear() {
        sharedPreferences.edit().clear().commit();
    }
}
